package xj.graph2d.template.uml;

import xj.graph2d.AbstractModelListener;
import xj.graph2d.DrawShape;
import xj.graph2d.GraphNodeBase;
import xj.model.uml.ActivityNode;

public class UMLActivityNodeModelListener extends AbstractModelListener {

  public UMLActivityNodeModelListener() {
  }

  public UMLActivityNodeModelListener(Object model, DrawShape shape) {
    super(model, shape);
  }

  @Override
  public void updateModel() {
    if (shape instanceof GraphNodeBase && model instanceof ActivityNode) {
      GraphNodeBase anode = (GraphNodeBase) shape;
      ActivityNode amodel = (ActivityNode) model;
      String name = anode.getLabel();
      if (name != null) {
	amodel.setName(name);
      }
    }
  }

  @Override
  public void updateShape() {
    if (shape instanceof GraphNodeBase && model instanceof ActivityNode) {
      GraphNodeBase anode = (GraphNodeBase) shape;
      ActivityNode amodel = (ActivityNode) model;
      String name = amodel.getName();
      if (name != null) {
	anode.setLabel(name);
      }
    }
  }

}
